# Sustainable Office Designer
# by Fabian Ritter <Fabian.Ritter@live.de>, 2012

require("SOD/tools/OpenStudio/Collection")
require("SOD/tools/SGhash")

require("SOD/model/SketchInfoContainer")
require("SOD/model/projectInfo")
require("SOD/model/drawModelInterface")

module SOD
  
  class ModelInterface
    
    attr_reader :name, :sketchInfo, :barInfo, :cores, :sgHash
    attr_reader :drawVolumes, :drawConstruction, :drawFootprint, :reset
    attr_accessor :footprintID
    
    alias :sketchInfoContainer :sketchInfo
    alias :projectInfo :barInfo
    
    def initialize(name = "Default_Block")
      @name = name
      @sketchInfo = SketchInfoContainer.new
      @barInfo = ProjectInfo.new
      @footprintID = nil
      @cores = Collection.new
      @drawModelInterface = DrawModelInterface.new
      @sgHash = SGhash.new
      @checkingTools = CheckingTools.new
    end
    
    def drawVolumes
      @drawModelInterface.drawVolumes( self )
    end
    
    def update_SGhash
      #self.sketchInfo -> footpintLength, footprintWidth, direction, footprintPoints
      #self.barInfo -> roomsize, flexibility, numberOfStoreys, minRoomHeight /
      #-> minConstructionHeight, overallHeight, totalHeight, (update_values)?
      @sgHash.update_by_model( self )
    end
    
    def drawConstruction
      @drawModelInterface.drawConstruction( self )
    end
    
    def drawFootprint
      @drawModelInterface.drawFootprint( self )
      if not @cores.empty?
        @cores.each { |c| drawCore(c) }
      end
    end
    
    def drawCores( core )
      pts = core.points
      #...
    end
    
    def reset
      @drawModelInterface.reset
    end
    
    def check_if_intersect?
      @checkingTools.intersect?( self )
    end
    
  end
  
end

